package com.df.ez_game.server.logic;

import com.df.ez_game.server.*;
import io.netty.channel.Channel;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.HashSet;
import java.util.Set;
import java.util.function.Consumer;

@Accessors(chain = true)
@Data
public class LogicSettings {
    //服务器节点类型，默认是加入集群的逻辑服
    NodeType nodeType = NodeType.Logic;
    String brokerAddr;//启动服务器得时候链接得broker地址 ip:port 格式。需要加入集群模式得时候才会用
    Integer port;//服务的端口
    //对外的协议(单体应用的时候才拥有)
    Integer netProtoc = NetProtocType.TCP.getValue();
    Integer msgProtoc = MsgProtocType.JSON.getValue();

    //消息队列的大小
    Integer msgQueueDefaultSize;

    //心跳配置(心跳事件回调？)
    private int readIdleTime = 30;
    private int writeIdleTime = 30;
    private int allIdleTime = 60;
    private HeartBeatCallBack heartBeatCallBack;

    private String wsPath;

    //TODO 设置controller扫描的包路径，当前是与springboot深度绑定的，先不处理这个
//    private String controllerScanPackage;
    Set<Object> controllerInstance = new HashSet<>();

    //继承了IPushMsgEnum接口的枚举
    Set<Class> pushEnumClass = new HashSet<>();
    //订阅异常的类，会解析静态final，且是EzGameBusinessException类型的字段收集异常
    Set<Class> exceptionClass = new HashSet<>();

    //启动成功的回调，TODO 回调执行顺序问题，需要定义排序的接口
    Set<Consumer<Channel>> startSuccessCb = new HashSet<>();
    //启动失败的回调 TODO 回调执行顺序问题，需要定义排序的接口
    Set<Consumer<Channel>> startFailCb = new HashSet<>();

    //消息拦截器，统计信息，注入自己的上下文数据,注意拦截器顺序
    Set<IMsgFilter> filters = new HashSet<>();



    //消息队列选择器
    IMsgQueueSelector msgQueueSelector;


    //声明周期回调
    ISessionLifecycle sessionLifecycle;

    private boolean debug = false;


    //文档服是否启动
    private boolean docServer = false;
    private Integer docServerPort;
}
